﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace JKDD.doctor
{
    public partial class doctorLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string num = txtNumber.Text.ToString();
            string pass = txtPass.Text.ToString();
            string secury = txtSecury.Text.ToString();
            string code = HttpContext.Current.Application["Code"].ToString();
            if (num.Trim().Length > 0 && pass.Trim().Length > 0 && secury.Trim().Length > 0)
            {
                if (secury.Trim() == code)
                {
                    string sql;
                    sql = "select * from TB_DOCTOR_INFO where SREGISTERID='" + num.Trim() + "' and SPASS='" + pass.Trim() + "'";
                    try
                    {
                        DataTable dt = operateDB.GetDataTable(sql);
                        if (dt.Rows.Count > 0)
                        {
                            sql = "select SSTATUS from TB_DOCTOR_INFO where SREGISTERID='" + num.Trim() + "' and SPASS='" + pass.Trim() + "'";
                            dt = operateDB.GetDataTable(sql);
                            string str = dt.Rows[0]["SSTATUS"].ToString();
                            if (str == "1")
                            {
                                Response.Redirect("doctorIndex.aspx?doctorNum=" + num);
                            }
                            else
                            {
                                lblError.Text = "对不起，您还没通过医生身份认证！";
                            }
                        }
                        else
                        {
                            txtPass.Text = "";
                            lblError.Text = "网号或密码不正确！";
                        }
                    }
                    catch (Exception exc)
                    {
                        txtPass.Text = "";
                        lblError.Text = "服务器错误，暂时不能登陆！";
                    }
                }
                else
                {
                    txtPass.Text = "";
                    lblError.Text = "验证码错误！";
                }
            }
            else
            {
                txtPass.Text = "";
                lblError.Text = "网号或密码或验证码不能为空！";
            }
        }
    }
}
